//app.js
App({
  onLaunch: function () {
   if(!this.getUkey()){
     wx.redirectTo({
       url: '/pages/login/login',
     })
   }
  },
  getUkey: function () {
    var ukey;
    if (this.globalData.userInfo) {
      ukey = this.globalData.userInfo.ukey;
    } else {
      ukey = wx.getStorageSync('userinfo').ukey;//同步获取
    }
    return ukey ? ukey : "";
  },
  logout: function () {
    var that = this;
    wx.clearStorage({
      success: function (res) {
        that.globalData.userInfo = "";
        wx.showToast({
          title: '退出成功！',
          icon: 'success',
          duration: 2000,
          success: function () {
            setTimeout(function () {
              wx.reLaunch({
                url: '/pages/login/login'
              })
            }, 1000)
          }
        })
      }
    });

  },
  globalData: {
    userInfo:""
    // userInfo: {
    //   ukey: "ae0a47f8f1201e50"
    // }
  }
})